package jd.d20211009.t1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.Map;

/**

 * @author habitplus
 * @since 2021-10-09 19:34
 */
public class Main {
    static final StreamTokenizer st =
            new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

    static int nextInt() {
        try {
            st.nextToken();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return (int) st.nval;
    }

    public static void main(String[] args) {
        int n = nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        int[] ans = handle(arr);

        System.out.println(ans[0] + " " + ans[1]);
    }

    private static int[] handle(int[] arr) {
        if (arr == null || arr.length == 0) {
            return new int[]{-1, -1};
        }

        HashMap<Integer, int[]> map = new HashMap<>();
        int maxTimes = 0;
        int num = 0;
        int n = arr.length;
        int[] tt;
        for (int i = 0; i < n; i++) {
            if (map.containsKey(arr[i])) {
                tt = map.get(arr[i]);
                tt[0]++;
                tt[2] = i;
                map.put(arr[i], tt);
            } else {
                tt = new int[3];
                tt[0] = 1;
                tt[1] = i;
                tt[2] = i;
                map.put(arr[i], tt);
            }

            if (maxTimes < tt[0]) {
//                num = e;
                maxTimes = tt[0];
            }
        }

        int minLen = Integer.MAX_VALUE;
        int a = -1;
        int b = -1;

        for(Map.Entry<Integer, int[]> e : map.entrySet()) {
            tt = e.getValue();
            if (tt[0] == maxTimes) {
                if (tt[2] - tt[1] + 1 < minLen) {
                    minLen = tt[2] - tt[1] + 1;
                    a = tt[1];
                    b = tt[2];
                }
            }
        }

//        for (int i = 0; i < arr.length; i++) {
//            if (arr[i] == num) {
//                a = i + 1;
//                break;
//            }
//        }
//
//        for (int i = arr.length - 1; i >= 0; i--) {
//            if (arr[i] == num) {
//                b = i + 1;
//                break;
//            }
//        }

        return new int[] {a, b};
    }
}
